package day03;

import java.util.Date;

/**
 * 定义私有属性:
 * String name;
 * int age;
 * String gender;
 * int salary;
 * Date hiredate;//入职时间
 * 
 * 定义构造方法，以及属性get,set方法.
 * 定义toString方法，格式如:
 *    姓名:张三,年龄:25,性别:男,薪资:5000,入职时间:2006-02-15
 * 
 * 定义equals方法，要求只要名字相同，则认为内容一致。
 * @author Bonnie
 *
 */
class Per{
	private String name;
	 private int age;
	 private  String gender;
	 private int salary;
	 private Date hiredate;
	 public Per(String name,int age,String gender,int salary,Date hiredate) {
		 this.age=age;
		 this.gender=gender;
		 this.salary=salary;
		 this.hiredate=hiredate;
		 this.name=name;
	 }
	private String getName() {
		return name;
	}
	private void setName(String name) {
		this.name = name;
	}
	private int getAge() {
		return age;
	}
	private void setAge(int age) {
		this.age = age;
	}
	private String getGender() {
		return gender;
	}
	private void setGender(String gender) {
		this.gender = gender;
	}
	private int getSalary() {
		return salary;
	}
	private void setSalary(int salary) {
		this.salary = salary;
	}
	private Date getHiredate() {
		return hiredate;
	}
	private void setHiredate(Date hiredate) {
		this.hiredate = hiredate;
	}
	//重写toString
	public String toString() {
		return "姓名:" + name + ", 年龄:" + age + ", 性别:" + gender + ", 薪资:" + salary + ", 入职时间:"
				+ hiredate ;
	}
	
	//重写equals
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Per other = (Per) obj;
		if (name == null) {
			if (other.name != null)
				return false;
		} else if (!name.equals(other.name))
			return false;
		return true;
	}
	 
	
	
	
}
public class Emp {
	public static void main(String[] agrs) {
		Per w=new Per("小猪", 20, "男", 5000, null);
		Per m=new Per("小猪", 566, "女", 7000, null);
		System.out.println(w);
		System.out.println(w.equals(m));
		
	}

}
